package com.renwei.yunlong.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;

import com.renwei.yunlong.R;
import com.renwei.yunlong.base.BaseActivity;
import com.renwei.yunlong.http.HttpPresenter;
import com.renwei.yunlong.http.HttpTaskListener;
import com.renwei.yunlong.utils.JsonMapUtil;
import com.renwei.yunlong.utils.LogUtil;

import java.util.HashMap;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;


/**
 * Project :  yunaandroid.
 * Package name: PACKAGE_NAME
 * Created by :  Benjamin.
 * Created time: 2017/10/29 20:12
 * Changed by :  Benjamin.
 * Changed time: 2017/10/29 20:12
 * Class description:
 */

public class TempActivity extends BaseActivity {


    @Bind(R.id.btn1)
    Button btn1;
    @Bind(R.id.btn2)
    Button btn2;
    @Bind(R.id.btn3)
    Button btn3;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_temp);
        ButterKnife.bind(this);

    }

    @OnClick({R.id.btn1, R.id.btn2, R.id.btn3})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn1:
                HashMap<String,String> map=new HashMap<>();
                map.put("order_id","180414134208000007");
                map.put("composite_score","1");
                map.put("appearance_score","1");
                map.put("clean_score","1");
                map.put("attitude_score","1");
                map.put("evaluation_content","下班");
                map.put("image_ids","860");
                initData(JsonMapUtil.mapToJson(map));
                break;
            case R.id.btn2:
                break;
            case R.id.btn3:
                break;
            default:
                break;
        }
    }



    public void initData(String jsonBean) {
        String  url="https://test.weifengchuxing.com/api/c/order/evaluation";
        HttpPresenter hp = new HttpPresenter(this);
        hp.setUrl(url);
        hp.putHead("Authorization","Bearer 6fd73a7f94e2c3919b5acb9e5a847c1e");
        hp.putHead("Content-Type","application/x-www-form-urlencoded");
        hp.putHead("Accept","application/x.VFLY.v2+json");
        hp.putHead("client","web");
        hp.putParam("jsonBean", jsonBean);
        hp.setshowDialogcontent("正在添加好友");
        hp.setRequsetId(999);
        hp.setCallBack(new HttpTaskListener() {
            @Override
            public void onSuccess(int requestId, String result) {
                LogUtil.e(result);

            }

            @Override
            public void onException(int requestId, String code) {
                LogUtil.e("错误消息："+code);
            }
        });
        hp.post();

    }
}



